﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MethodWorx.CMS.Services;
using MethodWorx.Core.DomainModel;
using Moq;
using MethodWorx.CMS.Content;
using MethodWorx.CMS.Requests;
using MethodWorx.CMS.UI.Tests.Doubles;

namespace MethodWorx.CMS.UI.Tests.Services
{
    [TestClass]
    public class ContentTemplateServiceTests
    {
        private StubUnitOfWorkFactory suowf = new StubUnitOfWorkFactory();
        private ContentTemplateService CreateSystemUnderTest()
        {
            ContentTemplateService service = new ContentTemplateService(
                this.suowf,
                new Mock<IContentTemplateRepository>().Object);

            return service;
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Ensure_UpdateContentTemplateBasicDetails_Throws_ArgumentNullException_When_Null_Parameters_Are_Passed()
        {
            var service = this.CreateSystemUnderTest();
            service.UpdateContentTemplateBasicDetails(null);
        }

        [TestMethod]
        public void Ensure_UpdateContentTemplateBasicDetails_Updates_The_Content_Template()
        {
          /*  var ct = new ContentTemplate()
            {
                Id = Guid.NewGuid(),
                Name ="Name",
                Description = "Description"
            };

            var service = this.CreateSystemUnderTest();
            service.UpdateContentTemplateBasicDetails(new UpdateContentTemplateBasicDetailsRequestDouble(ct));

            //  did we start a unit of work
            Assert.IsTrue(suowf.UnitsOfWork.Any());
            //  did we commit a unit of work
            Assert.IsTrue(suowf.UnitsOfWork.First().IsCommited);
            //  and did we write the object
            Assert.IsTrue(suowf.UnitsOfWork.First().Changed.Contains(ct));*/
        }

        [TestMethod]
        public void Ensure_UpdateContentTemplateBasicDetails_Does_Not_Change_The_Request()
        {
           /* var ct = new ContentTemplate()
            {
                Id = Guid.NewGuid(),
                Name = "Name",
                Description = "Description"
            };

            var service = this.CreateSystemUnderTest();
            service.UpdateContentTemplateBasicDetails(new UpdateContentTemplateBasicDetailsRequestDouble(ct));

            Assert.IsTrue(ct.Name == "Name");
            Assert.IsTrue(ct.Description == "Description");*/
        }
    }
}
